package com.example.peanutsubway.service.abst;


import com.example.peanutsubway.dao.AdminUserDao;
import com.example.peanutsubway.dao.impl.AdminUserDaoImpl;
import com.example.peanutsubway.entity.AdminUserinfo;
import com.example.peanutsubway.entity.RoleInfo;
import com.example.peanutsubway.service.AdminUserService;
import com.example.peanutsubway.util.PageInfo;
import com.example.peanutsubway.vo.UserInfo;

import java.sql.Connection;
import java.util.List;

/**
 * 抽象类中放直接调用dao中的方法
 *
 * @Author：liulei
 * @Version：1.0
 * @Date：2021/10/11-16:49
 * @Since:jdk1.8
 * @Description:
 */
public abstract class AdminUserServiceAbst implements AdminUserService {

    public void setConnection(Connection connection) {}

    private AdminUserDao adminUserDao = new AdminUserDaoImpl();

    @Override
    public UserInfo login(String name, String pwd) {
        return adminUserDao.login(name, pwd);
    }

    @Override
    public PageInfo findAllUser(String nowPage, String pageNum) {
        Integer count = adminUserDao.userCount();
        PageInfo<UserInfo> page = new PageInfo(nowPage,pageNum,count);
        List<UserInfo> allUser = adminUserDao.findAllUser(page);
        page.setDataList(allUser);
        return page;
    }

    @Override
    public Boolean register(AdminUserinfo adminUserinfo) {
        return adminUserDao.register(adminUserinfo);
    }

    @Override
    public List<RoleInfo> findAllRole() {
        return adminUserDao.findAllRole();
    }




    @Override
    public Boolean updateRoleMessage(AdminUserinfo adminUserinfo) {
        return adminUserDao.updateRoleMessage(adminUserinfo);
    }

    @Override
    public Boolean updateUser(AdminUserinfo adminUserinfo) {
        return adminUserDao.updateUser(adminUserinfo);
    }

    @Override
    public Boolean addUser(AdminUserinfo adminUserinfo) {
        return adminUserDao.addUser(adminUserinfo);
    }

    @Override
    public Boolean deleteUser(Integer id) {
        return adminUserDao.deleteUser(id);
    }
}
